/*
 * Copyright 2010 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.google.android.apps.mytracks.io.docs;

import junit.framework.TestCase;

/**
 * This class tests {@link DocsTagBuilder}
 * 
 * @author Matthew Simmons
 */
public class DocsTagBuilderTest extends TestCase {
  public void testAppend() {
    assertEquals("<gsx:tag><![CDATA[value]]></gsx:tag>", 
        new DocsTagBuilder(false).append("tag", "value").build());
  }
  
  public void testMultiAppend() {
    String actual = new DocsTagBuilder(false)
        .append("tag1", "value1")
        .append("tag2", "value2")
        .build();
    
    assertEquals("<gsx:tag1><![CDATA[value1]]></gsx:tag1>"
        + "<gsx:tag2><![CDATA[value2]]></gsx:tag2>", actual); 
  }
  
  public void testAppendLargeUnits_imperial() {
    assertEquals("<gsx:tag><![CDATA[62.14]]></gsx:tag>",
        new DocsTagBuilder(false).appendLargeUnits("tag", 100.0).build());
  }
  
  public void testAppendLargeUnits_metric() {
    assertEquals("<gsx:tag><![CDATA[100.00]]></gsx:tag>",
        new DocsTagBuilder(true).appendLargeUnits("tag", 100.0).build());
  }
  
  public void testAppendSmallUnits_imperial() {
    assertEquals("<gsx:tag><![CDATA[328]]></gsx:tag>",
        new DocsTagBuilder(false).appendSmallUnits("tag", 100.0).build());
  }
  
  public void testAppendSmallUnits_metric() {
    assertEquals("<gsx:tag><![CDATA[100]]></gsx:tag>",
        new DocsTagBuilder(true).appendSmallUnits("tag", 100.0).build());
  }
}
